         
function getGraphicsDrill(){
    try{
        //var _loading = document.getElementById(loading);
        //if(_loading) _loading.style.visibility="visible";
        if(document.getElementById("chartdivDrill"))this.setTimeout(getGraphicsDrillImp(), 1000);
    }catch(ex){}
}

function getGraphicsDrillImp(){
    //alert("ENTRE");
    var pointer = document.getElementById("pointer").getAttribute("value");
    var dimenCut = document.getElementById("dimensionalCut").getAttribute("value");
    var dimensionMember = document.getElementById("dimensionMember").getAttribute("value");
    var startDate = document.getElementById("startDate").getAttribute("value");
    var endDate = document.getElementById("endDate").getAttribute("value");
    var fontSize = document.getElementById("font").getAttribute("value");
    //alert("El tam de: " + fontSize);

    var path="ajaxDrillDashboard.do?pointer="+pointer+"&dimensionalCut="+dimenCut+"&dimensionMember="+dimensionMember+"&startDate="+startDate+"&endDate=" + endDate;
    //alert("Path: "+ path );
    var ajax = new accesoAJAX.CargadorDeDatos("POST",path,
        function(data){
            //alert(data);
            document.getElementById("chartdivDrill").innerHTML = "";
            var chart;
            var legend;

            var XMLresponse = buildXMLFromString(data);
            var elems = XMLresponse.getElementsByTagName("register");
            var graphics = XMLresponse.getElementsByTagName("graphics");
            var scoresInfo = XMLresponse.getElementsByTagName("scoreInfo");
            if(elems && graphics){

                var datos = new Array();
                           

                for(var i=0;i<elems.length;i++){
                    // alert(elems[i]+","+i);
                    //String that will eval
                    var evalstring = "datos["+i+"] = {";
                    var register = elems[i];


                    var date = register.getAttribute("date");
                    evalstring+="period:'"+date+"'";

                    var datas = register.childNodes;
                    //var real,goal;
                    for(var j=0;j<datas.length;j++){
                        if(datas[j].getAttribute){
                            var type = datas[j].getAttribute("cut")+"_"+ datas[j].getAttribute("type");
                            var value = datas[j].getAttribute("value");
                            var dataeval = ","+type+":"+value;
                            evalstring += dataeval;

                        }
                    }
                    evalstring+="};"
                          
                    //alert("EvalString" + evalstring);
                    eval(evalstring);
                    console.log(datos[i]);
                }

                var scoreInfo = scoresInfo[0];
                var unit = scoreInfo.getAttribute("unit");

                chart = new AmCharts.AmSerialChart();
                chart.dataProvider = datos;
                chart.categoryField = "period";
                chart.startDuration = 1;
                chart.marginTop = 25;
                chart.marginLeft = 85;
                chart.rotate = false;

                for(var i=0;i<graphics.length;i++){
                    var register = graphics[i];
                    var dimensionalCut = register.getAttribute("dimensionalCut");
                    var comparator = register.getAttribute("comparator");
                    var valueFieldGraphic= dimensionalCut+"_"+comparator;

                                
                    if(comparator == 'Real'){
                        var graph1 = new AmCharts.AmGraph();
                        graph1.title = valueFieldGraphic;
                        graph1.valueField = valueFieldGraphic;
                        graph1.type = "column";
                        graph1.balloonText="[[value]]"+"("+unit+")"+" -- " + valueFieldGraphic ;
                        graph1.lineAlpha = 0;
                        graph1.fillAlphas = 1;
                        chart.addGraph(graph1);
                    }else{
                        var graph3 = new AmCharts.AmGraph();
                        graph3.title = valueFieldGraphic;
                        graph3.valueField = valueFieldGraphic;
                        graph3.type = "line";
                        graph3.lineThickness = 2;
                        graph3.balloonText="[[value]]"+"("+unit+")"+" -- " + valueFieldGraphic ;;
                        graph3.bullet = "round";
                        graph3.bullet_size = 100;
                        graph3.fillAlphas = 0;
                        chart.addGraph(graph3);

                    }
                               
                }
                           

                var catAxis = chart.categoryAxis;
                catAxis.gridPosition = "start";
                catAxis.dashLength = 5;

                var valAxis = new AmCharts.ValueAxis();
                valAxis.dashLength = 5;
                chart.addValueAxis(valAxis);

                var valAxis2 = new AmCharts.ValueAxis();
                valAxis2.position = "top";
                chart.addValueAxis(valAxis2);

                var legend = new AmCharts.AmLegend();
                //legend.align = "center";
                legend.fontSize = fontSize;
                legend.marginLeft = 47;
                chart.addLegend(legend);

                chart.write("chartdivDrill");
            }
        // document.getElementById(loading).style.visibility="hidden";
        });
}

